#!/bin/bash
# -------------------------------------------------------------------------------
# Filename:     stop_web_demo.sh
# Update:       2025/04/16
# Description:  停止Web Demo服务
# Example:      ./stop_web_demo.sh
# Depends:      离线Docker镜像, Python, Torch2.5环境
# -------------------------------------------------------------------------------
set -eo pipefail
# -------------------------- 颜色定义 --------------------------
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
CYAN='\033[36m'
NC='\033[0m'

# -------------------------- 基础配置 --------------------------
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT_DIR=$(dirname "${SCRIPT_DIR}")
SCRIPT_FILE="clean.sh"

# -------------------------- 函数定义 --------------------------
error() {
  echo -e "${RED}[ERROR]${NC} $1" >&2
  exit 1
}

info() {
  echo -e "${CYAN}[INFO]${NC} $1"
}

success() {
  echo -e "${GREEN}[SUCCESS]${NC} $1"
}

# -------------------------- 执行流程 --------------------------
{
  # 停止容器服务
  info "停止容器服务..."
  # ./clean.sh
  pushd "${ROOT_DIR}" > /dev/null
  "./${SCRIPT_FILE}"
  popd > /dev/null

  success "服务已停止!"
}
